package com.sc.nft.admin.controller;

import cn.hutool.core.bean.BeanUtil;
import com.sc.nft.admin.request.OrderExportRequest;
import com.sc.nft.admin.request.RoughStoneOrderRequest;
import com.sc.nft.admin.request.TempRequest;
import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.entity.TempOrderDetail;
import com.sc.nft.entity.TempRoughStoneOrder;
import com.sc.nft.entity.vo.OrderSimpleVO;
import com.sc.nft.entity.vo.RoughStoneOrderVO;
import com.sc.nft.enums.OrderExportTypeEnum;
import com.sc.nft.service.TempRoughStoneOrderService;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @author 朱梦晨
 * @Description:
 * @date 2024-08-02
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/temp/roughStoneOrder")
@Api(tags="原石订单导出模块")
public class TempRoughStoneOrderController {


    private final TempRoughStoneOrderService tempRoughStoneOrderService;


    @PostMapping(value = "/orderExport", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "原石订单导出", notes = "原石订单导出", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result tempOrderExcel(@Valid @RequestBody RoughStoneOrderRequest request){

        return Result.success(tempRoughStoneOrderService.saveTempRoughStoneOrder(request.getOrderNo(), request.getStatus(),
                request.getTypeClassify(), request.getStartOrderTime(), request.getEndOrderTime(), request.getStartPayTime(),
                request.getEndPayTime(),request.getUserTel()));
    }

    @PostMapping(value = "/download", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "原石订单导出下载", notes = "原石订单导出下载", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<List<RoughStoneOrderVO>> findTempOrderList(@Valid @RequestBody TempRequest request){
        List<TempRoughStoneOrder> tempRoughStoneOrderList = tempRoughStoneOrderService.findTempRoughStoneOrderList(request.getExportRecordsId());
        List<RoughStoneOrderVO> roughStoneOrderVOList = BeanUtil.copyToList(tempRoughStoneOrderList, RoughStoneOrderVO.class);
        return Result.success(roughStoneOrderVOList);
    }



}
